package com.jaws.demo.schedule.task;

import com.jaws.core.common.util.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class JawsBatchJob implements Job {

	@Resource
	private JobLauncher jobLauncher;

	@Resource
	private org.springframework.batch.core.Job importJob;

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		System.out.println(DateUtil.getCurrentDateTime() + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> this is JawsBatchJob !!!!!!!!!!!!!!!!!!!");
		JobParameters jobParameters = new JobParametersBuilder()
				.addLong("time", System.currentTimeMillis())
				.addString("input.file.name", "account.csv")
				.toJobParameters();

		try {
			// 开启注解执行Batch JOB
//			jobLauncher.run(importJob, jobParameters);
		} catch (Exception e) {
			System.out.println(">>>>>   JawsBatchJob done !!!!");
		}
		System.out.println(">>>>>   JawsBatchJob SUCCESS !!!!");
	}
}
